import apiClient from './config'

/**
 * 系统设置相关 API
 */
export const settingsAPI = {
  /**
   * 获取系统配置
   * @returns {Promise} 系统配置
   */
  getSystemSettings() {
    return apiClient.get('/settings/system')
  },

  /**
   * 更新系统配置
   * @param {Object} settings - 系统配置
   * @returns {Promise} 更新结果
   */
  updateSystemSettings(settings) {
    return apiClient.put('/settings/system', settings)
  },

  /**
   * 获取邮件配置
   * @returns {Promise} 邮件配置
   */
  getEmailSettings() {
    return apiClient.get('/settings/email')
  },

  /**
   * 更新邮件配置
   * @param {Object} emailSettings - 邮件配置
   * @returns {Promise} 更新结果
   */
  updateEmailSettings(emailSettings) {
    return apiClient.put('/settings/email', emailSettings)
  },

  /**
   * 测试邮件配置
   * @param {Object} emailSettings - 邮件配置
   * @returns {Promise} 测试结果
   */
  testEmailSettings(emailSettings) {
    return apiClient.post('/settings/email/test', emailSettings)
  },

  /**
   * 获取通知配置
   * @returns {Promise} 通知配置
   */
  getNotificationSettings() {
    return apiClient.get('/settings/notifications')
  },

  /**
   * 更新通知配置
   * @param {Object} notificationSettings - 通知配置
   * @returns {Promise} 更新结果
   */
  updateNotificationSettings(notificationSettings) {
    return apiClient.put('/settings/notifications', notificationSettings)
  },

  /**
   * 获取安全配置
   * @returns {Promise} 安全配置
   */
  getSecuritySettings() {
    return apiClient.get('/settings/security')
  },

  /**
   * 更新安全配置
   * @param {Object} securitySettings - 安全配置
   * @returns {Promise} 更新结果
   */
  updateSecuritySettings(securitySettings) {
    return apiClient.put('/settings/security', securitySettings)
  },

  /**
   * 获取备份配置
   * @returns {Promise} 备份配置
   */
  getBackupSettings() {
    return apiClient.get('/settings/backup')
  },

  /**
   * 更新备份配置
   * @param {Object} backupSettings - 备份配置
   * @returns {Promise} 更新结果
   */
  updateBackupSettings(backupSettings) {
    return apiClient.put('/settings/backup', backupSettings)
  },

  /**
   * 创建数据库备份
   * @returns {Promise} 备份结果
   */
  createBackup() {
    return apiClient.post('/settings/backup/create')
  },

  /**
   * 获取备份列表
   * @returns {Promise} 备份列表
   */
  getBackupList() {
    return apiClient.get('/settings/backup/list')
  },

  /**
   * 删除备份
   * @param {string} backupId - 备份ID
   * @returns {Promise} 删除结果
   */
  deleteBackup(backupId) {
    return apiClient.delete(`/settings/backup/${backupId}`)
  },

  /**
   * 恢复数据库
   * @param {string} backupId - 备份ID
   * @returns {Promise} 恢复结果
   */
  restoreBackup(backupId) {
    return apiClient.post(`/settings/backup/${backupId}/restore`)
  },

  /**
   * 获取系统日志配置
   * @returns {Promise} 日志配置
   */
  getLogSettings() {
    return apiClient.get('/settings/logs')
  },

  /**
   * 更新系统日志配置
   * @param {Object} logSettings - 日志配置
   * @returns {Promise} 更新结果
   */
  updateLogSettings(logSettings) {
    return apiClient.put('/settings/logs', logSettings)
  },

  /**
   * 清理系统日志
   * @param {Object} params - 清理参数
   * @returns {Promise} 清理结果
   */
  cleanupLogs(params) {
    return apiClient.post('/settings/logs/cleanup', params)
  },

  /**
   * 获取系统信息
   * @returns {Promise} 系统信息
   */
  getSystemInfo() {
    return apiClient.get('/settings/system/info')
  },

  /**
   * 重启系统服务
   * @param {string} service - 服务名称
   * @returns {Promise} 重启结果
   */
  restartService(service) {
    return apiClient.post(`/settings/system/restart/${service}`)
  },

  /**
   * 获取系统状态
   * @returns {Promise} 系统状态
   */
  getSystemStatus() {
    return apiClient.get('/settings/system/status')
  }
}

